package com.app.micaihu.bean.infor;

import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.app.micaihu.R;
import com.app.micaihu.configure.Config;
import com.app.utils.util.ToastUtils;
import com.blankj.utilcode.util.Utils;
import com.jeremyliao.liveeventbus.LiveEventBus;

/**
 * Created by Guo on 2016/7/25.
 * <p>
 * 所有获得积分的bean类->返回是否调用任务中心接口
 */
public class GetTaskBean {
    private String isGetTask;//是否拉取任务 1是 0否
    private String militaryExploit;//
    private String militarPay;//
    private String armyGold;//
    private boolean isArmy;

    public boolean isArmy() {
        return isArmy;
    }

    public void setArmy(boolean army) {
        isArmy = army;
    }

    public String getArmyGold() {
        return armyGold;
    }

    public void setArmyGold(String armyGold) {
        this.armyGold = armyGold;
    }

    public boolean getIsGetTask() {
        return TextUtils.equals("1", isGetTask);
    }

    public boolean getIsGetTask(String taskName) {
        boolean b = TextUtils.equals("1", isGetTask);
        if (b) {
            toastTaskMsg(taskName);
        }
        return b;
    }

    public void setIsGetTask(String isGetTask) {
        this.isGetTask = isGetTask;
    }

    public String getMilitaryExploit() {
        return militaryExploit;
    }

    public void setMilitaryExploit(String militaryExploit) {
        this.militaryExploit = militaryExploit;
    }

    public String getMilitarPay() {
        return militarPay;
    }

    public void setMilitarPay(String militarPay) {
        this.militarPay = militarPay;
    }

    /**
     * 弹出增加的任务奖励
     *
     * @param taskName
     */
    public void toastTaskMsg(String taskName) {
//        if (TextUtils.isEmpty(taskName)) {
//            taskName = "";
//        }
        taskName = "";

        if (!TextUtils.isEmpty(militarPay) && !TextUtils.equals(militarPay, "0")) {
            taskName += "金币+" + militarPay;
        }
        if (!TextUtils.isEmpty(militaryExploit) && !TextUtils.equals(militaryExploit, "0")) {
            taskName += " 军功+" + militaryExploit;
        }
        View view = LayoutInflater.from(Utils.getApp()).inflate(R.layout.task_success_layout, null, false);
        TextView tvGold = view.findViewById(R.id.tvGold);
        TextView tvArmyGold = view.findViewById(R.id.tvArmyGold);
        tvGold.setText(taskName);
        if (!TextUtils.isEmpty(armyGold) && !TextUtils.equals(armyGold, "0")) {
            tvArmyGold.setText("军团币+" + armyGold);
        }
        ToastUtils.makeCustomView(view);
//        ToastUtils.makeText(R.drawable.task_pop_reward, taskName);
    }
}
